package com.xuyh.pdf.utils;

/**
 * @author xuyh
 * @email 497418972@qq.com
 * @data 2019年3月21日12:39:27
 * @description pdf页码
 */
public class PDFNum {
    private int start;
    private int end;

    public PDFNum(int start, int end) {
        this.start = start;
        this.end = end;
    }

    public static PDFNum newInstance(String start, String end) {
        int startNo = 1;
        int endNo = 0;
        if (start != null && !"".equals(start)) {
            startNo = Integer.valueOf(start);
        }
        if (end != null && !"".equals(end)) {
            endNo = Integer.valueOf(end);
        }
        if (startNo == 0) {
            startNo = 1;
        }
        return new PDFNum(startNo, endNo);
    }

    public static PDFNum newInstance(String no) {
        if (no.startsWith("-")) {
            no = 0 + no;
        }
        if (no.endsWith("-")) {
            no = no + 0;
        }
        String[] split = no.split("-");
        return newInstance(split[0], split[1]);
    }

    public int getStart() {
        return start;
    }

    public void setStart(int start) {
        if (start == 0) {
            start = 1;
        }
        this.start = start;
    }

    public int getEnd() {
        return end;
    }

    public void setEnd(int end) {
        this.end = end;
    }
}
